
#include "iostream"
using namespace std;
struct TreeNode{
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x):val(x),left(NULL),right(NULL){}
};
bool recur(TreeNode *L,TreeNode *R){
    if (L==NULL&&R==NULL)
        return true;
    if ((L==NULL||R==NULL)||L->val!=R->val)
        return false;
    return recur(L->left,R->right)&&recur(L->right,R->left);
}
bool isSymmetric(TreeNode *root){
    if (root== nullptr)
        return true;
    return recur(root->left,root->right);
}
